<?php
/**************************************************
 *  Created:  2010-06-08
 *
 *  推荐微博用户搜索
 *
 *  @Xweibo (C)1996-2099 SINA Inc.
 *  @Author zhenquan <zhenquan@staff.sina.com.cn>
 *
 ***************************************************/
class gtstar_mod
{
	/// 获取绑定信息
	function default_action() {
	
//		echo $_GET['gid'];
		$grpRst = DR('mgr/gtStarCom.getStarGroups','');
		$groups = &$grpRst['rst'];
		
		$result = DR('mgr/gtStarCom.getUsersByGid','', $_GET['gid']);

		$rs = '';
		if ($result['errno'] == 0) {
			$rs = &$result['rst'];
		}
		
			$uid = USER::uid();
			TPL :: assign('sina_uid', $uid);

			$rst = DR('xweibo/xwb.getFriendIds', '', $uid, null, null, -1, 5000);
			$rst = $rst['rst'];
			$ids = $rst['ids'];
			foreach($rs as $key => $row) {
				if (in_array($row['uid'], $ids)) {
					$rs[$key]['following'] = true;
				}
				if (in_array($row['rel_uid'], $ids)) {
					$rs[$key]['rel_following'] = true;
				}
			}
		
		TPL::assign('groups', $groups);
		TPL::assign('users', $rs);
		if( $_GET['gid']){
			TPL::assign('gid',  $_GET['gid']);
		}else{
			TPL::assign('gid',  0);
		}
		
		//-----------------
		// 右侧模块数据
		//add by gt
		//获取当前用户的粉丝列表id
		$fids = DR('xweibo/xwb.getFriendIds', '', USER::uid(), null, null, -1, 5000);
		$fids = $fids['rst']['ids'];
		

		$followId = DS('common/sysConfig.get','', 'guide_auto_follow_id');
		$result = DR('mgr/userRecommendCom.getUserById', '', $followId);

		$rst = '';
		if ($result['errno'] == 0) {
			$rst = &$result['rst'];


			if (!empty($rst)) {
				$comWeibos = array();
				foreach ($rst as $row) {
					foreach ($fids as $fid){
						
						if($fid == $row['rel_uid']){
							$isExist = false;
							foreach ($fids as $fid1){
								if($fid1 == $row['uid']){
									$isExist = true;
									break;
								}
							}
							$len = count($comWeibos);
							if(!$isExist && $len < 9){
								//echo $len;
								array_push($comWeibos, $row);
							}
						}
					}
				}
				

			}

		}
		//推荐关注
		TPL::assign('comWeibos', $comWeibos);
		// add by gt end 右侧推荐关注列表显示结束
		

		TPL::display('gtstar');
	}


}
?>